package com.jlkf.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import com.jlkf.pojo.CommonlyUsedAddress;
import com.jlkf.service.CommonlyUsedAddressService;
import com.platform.server.response.response.pojo.ReturnData;
import com.platform.server.util.StringTools;
/**
 * 常用地址
 * @author DN
 *
 */
@Controller
@RequestMapping("commonlyUsedAddress")
public class CommonlyUsedAddressController {

	@Autowired
	private CommonlyUsedAddressService  commonlyUsedAddressService;
	//常用地址
	@RequestMapping("getCommonlyUsedAddress")
	public Object getCommonlyUsedAddress(Long uId,Long classificationId,Integer pageNo,Integer pageSize){
		return commonlyUsedAddressService.getCommonlyUsedAddress(uId,classificationId,pageNo,pageSize);
	}
 	//设置常用地址
	@RequestMapping("setCommonAddress")
	public Object setCommonAddress(@RequestBody String json){
		CommonlyUsedAddress cua =StringTools.json2Obj(json, CommonlyUsedAddress.class);
		if(cua==null){
			return new ReturnData(201,"The parameter list cannot be empty！");
		}
		return commonlyUsedAddressService.setCommonAddress(cua.getuId(),cua.getType(),cua.getAddress(),cua.getPlaceId(),cua.getFullAddress());
	}
	//删除常用地址   type 1家 2公司
	@RequestMapping("deleteCommonAddress")
	public Object deleteCommonAddress(Long uId,Integer type){
		return commonlyUsedAddressService.deleteCommonAddress(uId,type);
	}
}
